
#include <assert.h>
#include "app_platform/cmd_obj.h"
#include "app_platform/cntl_info.h"
#include "app_platform/intf_service_control.h"
#include "logservice/logger.h"
#include "cooperatordao_adaptor.h"
#include "cooperatordao_req_resp.h"


std::string g_scooperatordaoStandAlone;
#include "app_platform/res_factory.h"
#include "c2cplatform/component/dal/dal_set.h"

using namespace c2cplatform::component::dal;

///////////////////////
// class CCooperatorDaoSvcFactory
int CCooperatorDaoSvcFactory::init(void* pvParam)
{
	IUserDefineCntl* pCntl = reinterpret_cast<IUserDefineCntl*>(pvParam);
	assert(pCntl);
		CDAL_SET->AddCmd("0xA0111803");
		CDAL_SET->AddCmd("0xA0101807");
		CDAL_SET->AddCmd("0xA0111801");
		CDAL_SET->AddCmd("0xA0111804");
		CDAL_SET->AddCmd("0xA0111802");
		CDAL_SET->AddCmd("0xA0111806");
		CDAL_SET->AddCmd("0xA0111805");
		CDAL_SET->AddCmd("0xA0101805");
		CDAL_SET->AddCmd("0xA0101802");
		CDAL_SET->AddCmd("0xA0101804");
		CDAL_SET->AddCmd("0xA0101801");
		CDAL_SET->AddCmd("0xA0101803");
		CDAL_SET->AddCmd("0xA0101806");

	return CCooperatorDao::Initialize(pCntl);
}

int CCooperatorDaoSvcFactory::CXYZTimerHandler::OnTimer(int iTimerId)
{
    assert(0);
	return 0;
}

int CCooperatorDaoSvcFactory::fini(void* pvParam)
{
    return 0;
}

uint32_t CCooperatorDaoSvcFactory::getCateId() const
{   
	//方法已废弃
    return 0;
}

IService* CCooperatorDaoSvcFactory::createService(uint32_t dwcmdId)
{
    return (new CCooperatorDaoService(dwcmdId));
}

void CCooperatorDaoSvcFactory::getServiceType(ServiceTypeMap_T& mapSvcType)
{
	mapSvcType[COOPERATORDAO_CHECKCOOPERATORPASSWD_REQ_CMD_ID] = true;
	mapSvcType[COOPERATORDAO_DELETECOOPERATORMONITORMODEL_REQ_CMD_ID] = true;
	mapSvcType[COOPERATORDAO_GETCOOPERATORBASEINFO_REQ_CMD_ID] = true;
	mapSvcType[COOPERATORDAO_GETCOOPERATORKEY_REQ_CMD_ID] = true;
	mapSvcType[COOPERATORDAO_GETCOOPERATORLICENSE_REQ_CMD_ID] = true;
	mapSvcType[COOPERATORDAO_GETCOOPERATORMONITORMODEL_REQ_CMD_ID] = true;
	mapSvcType[COOPERATORDAO_GETCOOPERATORMONITORMODELLIST_REQ_CMD_ID] = true;
	mapSvcType[COOPERATORDAO_SETCOOPERATORINFO_REQ_CMD_ID] = true;
	mapSvcType[COOPERATORDAO_SETCOOPERATORPASSWD_REQ_CMD_ID] = true;
	mapSvcType[COOPERATORDAO_SETCOOPERATORPRO_REQ_CMD_ID] = true;
	mapSvcType[COOPERATORDAO_UPDATECOOPERATORBASEINFO_REQ_CMD_ID] = true;
	mapSvcType[COOPERATORDAO_UPDATECOOPERATORLICENSE_REQ_CMD_ID] = true;
	mapSvcType[COOPERATORDAO_UPDATECOOPERATORMONITORMODEL_REQ_CMD_ID] = true;
}

////////////////////////
// class CCooperatorDaoService
CCooperatorDaoService::CCooperatorDaoService(uint32_t dwcmdId) 
: m_dwcmdId(dwcmdId)
{
    m_pSvc = new CCooperatorDao;
}

void CCooperatorDaoService::Reset() 
{ 
	m_pSvc -> Reset();
}
    
void CCooperatorDaoService::getCmdIdRange(uint32_t& dwcmdIdBegin, uint32_t& dwcmdIdEnd) const 
{ 
    dwcmdIdBegin = m_dwcmdId;
    dwcmdIdEnd = m_dwcmdId;
} 
	
int CCooperatorDaoService::Execute(CCmdObj& oCmd)
{
	switch(oCmd.getCmdId())
	{
	case COOPERATORDAO_CHECKCOOPERATORPASSWD_REQ_CMD_ID:
        return CheckCooperatorPassWd(oCmd);
	case COOPERATORDAO_DELETECOOPERATORMONITORMODEL_REQ_CMD_ID:
        return DeleteCooperatorMonitorModel(oCmd);
	case COOPERATORDAO_GETCOOPERATORBASEINFO_REQ_CMD_ID:
        return GetCooperatorBaseInfo(oCmd);
	case COOPERATORDAO_GETCOOPERATORKEY_REQ_CMD_ID:
        return GetCooperatorKey(oCmd);
	case COOPERATORDAO_GETCOOPERATORLICENSE_REQ_CMD_ID:
        return GetCooperatorLicense(oCmd);
	case COOPERATORDAO_GETCOOPERATORMONITORMODEL_REQ_CMD_ID:
        return GetCooperatorMonitorModel(oCmd);
	case COOPERATORDAO_GETCOOPERATORMONITORMODELLIST_REQ_CMD_ID:
        return GetCooperatorMonitorModelList(oCmd);
	case COOPERATORDAO_SETCOOPERATORINFO_REQ_CMD_ID:
        return SetCooperatorInfo(oCmd);
	case COOPERATORDAO_SETCOOPERATORPASSWD_REQ_CMD_ID:
        return SetCooperatorPassWd(oCmd);
	case COOPERATORDAO_SETCOOPERATORPRO_REQ_CMD_ID:
        return SetCooperatorPro(oCmd);
	case COOPERATORDAO_UPDATECOOPERATORBASEINFO_REQ_CMD_ID:
        return UpdateCooperatorBaseInfo(oCmd);
	case COOPERATORDAO_UPDATECOOPERATORLICENSE_REQ_CMD_ID:
        return UpdateCooperatorLicense(oCmd);
	case COOPERATORDAO_UPDATECOOPERATORMONITORMODEL_REQ_CMD_ID:
        return UpdateCooperatorMonitorModel(oCmd);
	default:
		assert(0);
	}
	return 0;
}

int CCooperatorDaoService::CheckCooperatorPassWd(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoCheckCooperatorPassWdReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoCheckCooperatorPassWdResp oResp;
	
    oResp.dwResult = m_pSvc->CheckCooperatorPassWd(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.cooperatorId,
		oReq.cooperatorPassword,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CCooperatorDaoService::DeleteCooperatorMonitorModel(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoDeleteCooperatorMonitorModelReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoDeleteCooperatorMonitorModelResp oResp;
	
    oResp.dwResult = m_pSvc->DeleteCooperatorMonitorModel(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.cooperatorId,
		oReq.modelId,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CCooperatorDaoService::GetCooperatorBaseInfo(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoGetCooperatorBaseInfoReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoGetCooperatorBaseInfoResp oResp;
	
    oResp.dwResult = m_pSvc->GetCooperatorBaseInfo(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.cooperatorId,
		oReq.inReserve,
		oReq.errmsg,
		oReq.cooperatorBaseInfoDdo,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.cooperatorBaseInfoDdo = oReq.cooperatorBaseInfoDdo;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CCooperatorDaoService::GetCooperatorKey(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoGetCooperatorKeyReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoGetCooperatorKeyResp oResp;
	
    oResp.dwResult = m_pSvc->GetCooperatorKey(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.cooperatorId,
		oReq.inReserve,
		oReq.errmsg,
		oReq.sCooperatorKey,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.sCooperatorKey = oReq.sCooperatorKey;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CCooperatorDaoService::GetCooperatorLicense(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoGetCooperatorLicenseReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoGetCooperatorLicenseResp oResp;
	
    oResp.dwResult = m_pSvc->GetCooperatorLicense(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.cooperatorId,
		oReq.licenseType,
		oReq.inReserve,
		oReq.errmsg,
		oReq.cooperatorLicenseDdo,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.cooperatorLicenseDdo = oReq.cooperatorLicenseDdo;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CCooperatorDaoService::GetCooperatorMonitorModel(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoGetCooperatorMonitorModelReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoGetCooperatorMonitorModelResp oResp;
	
    oResp.dwResult = m_pSvc->GetCooperatorMonitorModel(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.cooperatorId,
		oReq.modelId,
		oReq.inReserve,
		oReq.errmsg,
		oReq.CooperatorMonitorModelDdo,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.CooperatorMonitorModelDdo = oReq.CooperatorMonitorModelDdo;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CCooperatorDaoService::GetCooperatorMonitorModelList(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoGetCooperatorMonitorModelListReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoGetCooperatorMonitorModelListResp oResp;
	
    oResp.dwResult = m_pSvc->GetCooperatorMonitorModelList(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.cooperatorId,
		oReq.inReserve,
		oReq.errmsg,
		oReq.CooperatorMonitorModelDdo,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.CooperatorMonitorModelDdo = oReq.CooperatorMonitorModelDdo;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CCooperatorDaoService::SetCooperatorInfo(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoSetCooperatorInfoReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoSetCooperatorInfoResp oResp;
	
    oResp.dwResult = m_pSvc->SetCooperatorInfo(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.cooperatorSetDdo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CCooperatorDaoService::SetCooperatorPassWd(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoSetCooperatorPassWdReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoSetCooperatorPassWdResp oResp;
	
    oResp.dwResult = m_pSvc->SetCooperatorPassWd(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.cooperatorId,
		oReq.cooperatorOldPassword,
		oReq.cooperatorNewPassword,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CCooperatorDaoService::SetCooperatorPro(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoSetCooperatorProReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoSetCooperatorProResp oResp;
	
    oResp.dwResult = m_pSvc->SetCooperatorPro(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.cooperatorProDdo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CCooperatorDaoService::UpdateCooperatorBaseInfo(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoUpdateCooperatorBaseInfoReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoUpdateCooperatorBaseInfoResp oResp;
	
    oResp.dwResult = m_pSvc->UpdateCooperatorBaseInfo(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.cooperatorBaseInfoDdo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CCooperatorDaoService::UpdateCooperatorLicense(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoUpdateCooperatorLicenseReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoUpdateCooperatorLicenseResp oResp;
	
    oResp.dwResult = m_pSvc->UpdateCooperatorLicense(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.cooperatorLicenseDdo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CCooperatorDaoService::UpdateCooperatorMonitorModel(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CCooperatorDaoUpdateCooperatorMonitorModelReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	CCooperatorDaoUpdateCooperatorMonitorModelResp oResp;
	
    oResp.dwResult = m_pSvc->UpdateCooperatorMonitorModel(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.CooperatorMonitorModelDdo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


#include "svc_main.h"

IServiceFactory* GetServiceFactory(void)
{
    return CSvcFactorySingleton::Instance();
}
